package com.shrct.businessprocess.project.impl;

import com.shrct.businessprocess.project.RCSaleCommissionPayment;
import com.shrct.businessprocess.project.RCSaleCommissionPaymentCriteria;
import com.shrct.businessprocess.project.RCSalesAssignment;
import edu.fudan.mylang.pf.query.HQLBasedPagedQueryCriteria;
import java.util.Date;
import org.hibernate.Query;

public class RCSaleCommissionPaymentCriteriaImpl extends HQLBasedPagedQueryCriteria<RCSaleCommissionPayment> implements RCSaleCommissionPaymentCriteria {
  private Integer year;
  
  public Integer getYear() {
    return this.year;
  }
  
  public RCSaleCommissionPaymentCriteria setYear(final Integer year) {
    this.year = year;
    return this;			
    
  }
  
  private RCSalesAssignment saler;
  
  public RCSalesAssignment getSaler() {
    return this.saler;
  }
  
  public RCSaleCommissionPaymentCriteria setSaler(final RCSalesAssignment saler) {
    this.saler = saler;
    return this;			
    
  }
  
  private Date dateFrom;
  
  public Date getDateFrom() {
    return this.dateFrom;
  }
  
  public RCSaleCommissionPaymentCriteria setDateFrom(final Date dateFrom) {
    this.dateFrom = dateFrom;
    return this;			
    
  }
  
  private Date dateTo;
  
  public Date getDateTo() {
    return this.dateTo;
  }
  
  public RCSaleCommissionPaymentCriteria setDateTo(final Date dateTo) {
    this.dateTo = dateTo;
    return this;			
    
  }
  
  protected String buildHQLFrom() {
    return " from com.shrct.businessprocess.project.impl.RCSaleCommissionPaymentImpl this ";
  }
  
  protected String buildHQLBody() {
    String hql = "where 1 = 1 ";
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getYear()) ){
    	hql += " and ((this.yearPayment.year) = (:year))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getSaler()) ){
    	hql += " and ((this.yearPayment.saler) = (:saler))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getDateFrom()) ){
    	hql += " and ((this.date) >= (:dateFrom))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getDateTo()) ){
    	hql += " and ((this.date) <= (:dateTo))" ;
    }
    return hql;
    
  }
  
  public void initOrderBys() {
    addOrder("this.date",edu.fudan.mylang.pf.query.OrderItem.DESC);
  }
  
  protected void fillParameter(final Query query) {
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getYear())){
    	query.setParameter("year",getYear()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getSaler())){
    	query.setParameter("saler",getSaler()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getDateFrom())){
    	query.setParameter("dateFrom",getDateFrom()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getDateTo())){
    	query.setParameter("dateTo",getDateTo()) ;
    }			
    
  }
  
  protected Boolean isDistinct() {
    return false;
  }
  
  public RCSaleCommissionPaymentCriteriaImpl() {
    initOrderBys();
  }
}
